package com.sec.foodit;

import android.os.Bundle;
import android.os.Vibrator;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class MyBoardActivity extends Activity {
	
	private ActivityManager am = ActivityManager.getInstance();
	private Vibrator vibe = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		vibe = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);
		
		am.addActivity(this);
		
		final ActionBar actionBar = getActionBar();
 		actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO);
		
		setContentView(R.layout.activity_my_board);
		
		ImageButton btnWrite = (ImageButton)findViewById(R.id.btnWrite);
		
		btnWrite.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent("com.sec.foodit.PostFormActivity"));
			}
		});
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int menuId = item.getItemId();
		 
		//이벤트 할당
		switch(menuId) {
			case R.id.menu_nearby:
				startActivity(new Intent("com.sec.foodit.HomeScreenActivity"));
				break;
			case R.id.menu_myboard:
				startActivity(new Intent("com.sec.foodit.MyBoardActivity"));
				break;
			case R.id.menu_favorite:
				startActivity(new Intent("com.sec.foodit.FavoriteActivity"));
				break;
			case R.id.menu_settings:
				startActivity(new Intent("com.sec.foodit.SettingsActivity"));
				break;
		}
		overridePendingTransition(0, 0);
		finish();
		return true;
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater menuInflater = getMenuInflater(); 
		menuInflater.inflate(R.menu.activity_tabs, menu); 
		return true; 
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		am.removeActivity(this);
	}

}
